﻿using System;
using System.Data;
using System.Collections.Generic;
using System.Web.UI.HtmlControls;
using System.Web.UI;

using DevExpress.Web.ASPxHeadline;

using LMD.Lib.DataClass;
using LMD.Constant;
using LMD.Lib.Interface;
using LMD.Lib.Oracle;
using LMD.Lib.Controls;

/// <summary>
/// Summary description for UFTManager
/// </summary>
public static class UFTManager
{
    public static String BuildFieldSet_UFTData(this UFTData uftData)
    {
        // NEXT THIS ACOLLECTION SHOULD BE RETRIEVED FROM DATABASE
        Cached.EventTable evData = new Cached.EventTable();
        
        // NEXT THIS SHOULD LOOP FROM A ACOLLECTION, RETRIEVED FROM DATABASE
        String sxOutput = String.Empty;
        sxOutput += CustomControls.BuildFieldSet_PairedLabel("Jenis Event", evData.GetEventName(uftData.iEventId));
        sxOutput += CustomControls.BuildFieldSet_PairedLabel("Tema",  uftData.sxCode);
        sxOutput += CustomControls.BuildFieldSet_PairedLabel("Tanggal Event", 
            uftData.dtmEventDate.ToString("dd-MMM-yyyy"));
        sxOutput += CustomControls.BuildFieldSet_PairedLabel("Waktu",
           uftData.dtmStartTime.ToString("HH:mm") + " s.d. " + uftData.dtmEndTime.ToString("HH:mm"));
        sxOutput += CustomControls.BuildFieldSet_PairedLabel("Lokasi", uftData.sxLocation);
        if (uftData.iInvitationAttachmentId > 0)
        {
            String sxFileName = DBQuery.FileUploadTable.GetFileNameById(uftData.iInvitationAttachmentId);
            String sxLinkInvAttachment = CustomControls.Create_LinkDiv(KUFT.INVITATIONATTACHMENTID,
                "downloadFile('" + uftData.iInvitationAttachmentId.ToString() + "');"
                , sxFileName);
            sxOutput += CustomControls.BuildFieldSet_PairedLabel("Invitation Attachment", sxLinkInvAttachment);
        }
        else
        {
            sxOutput += CustomControls.BuildFieldSet_PairedLabel("Invitation Attachment", "No Attachment"); 
        }
        if (uftData.iEventAttachmentId > 0)
        {
            String sxFileName = DBQuery.FileUploadTable.GetFileNameById(uftData.iEventAttachmentId);
            String sxLinkEvtAttachment = CustomControls.Create_LinkDiv(KUFT.EVENTATTACHMENTID,
                "downloadFile('" + uftData.iEventAttachmentId.ToString() + "');"
                , sxFileName);
            sxOutput += CustomControls.BuildFieldSet_PairedLabel("Event Summary Attachment", sxLinkEvtAttachment);
        }
        else
        {
            sxOutput += CustomControls.BuildFieldSet_PairedLabel("Event Summary Attachment", "No Attachment");
        }
        if (uftData.iPresentationId > 0)
        {
            String sxFileName = DBQuery.FileUploadTable.GetFileNameById(uftData.iPresentationId);
            String sxLinkEvtAttachment = CustomControls.Create_LinkDiv(KUFT.PRESENTATIONID,
                "downloadFile('" + uftData.iPresentationId.ToString() + "');"
                , sxFileName);
            sxOutput += CustomControls.BuildFieldSet_PairedLabel("Event Presentation File", sxLinkEvtAttachment);
        }
        else
        {
            sxOutput += CustomControls.BuildFieldSet_PairedLabel("Event Presentation File", "No Attachment");
        }
        
        return sxOutput;
    }
    public static String BuildFieldSet_CloseEvent(this UFTData uftData)
    {
        String sxOutput = String.Empty;
        String sxFileName = DBQuery.FileUploadTable.GetFileNameById(uftData.iEventAttachmentId);
        String sxLinkInvAttachment = CustomControls.Create_LinkDiv(KUFT.EVENTATTACHMENTID,
            "downloadFile('" + uftData.iInvitationAttachmentId.ToString() + "');"
            , sxFileName);
        sxOutput += CustomControls.BuildFieldSet_PairedLabel("Event Summary Attachment", sxLinkInvAttachment);
        return sxOutput;
    }
    public static String BuildEditor_UFTData(this UFTData uftData)
    {
        Cached.EventTable evData = new Cached.EventTable();
        DataTable dtEventCode = evData.GetEventTable();
        Dictionary<String, String> dicHours = new Dictionary<String, String>();
        DateTime dtmDefault = DateTime.MinValue;
        for (int i = 0; i < 24; i++)
        {
            dtmDefault = dtmDefault.AddHours(-(dtmDefault.Hour)+i);
            dtmDefault = dtmDefault.AddMinutes(-(dtmDefault.Minute));
            dicHours.Add(dtmDefault.ToString("HH:mm"), dtmDefault.ToString("HH:mm"));
            dtmDefault = dtmDefault.AddHours(-(dtmDefault.Hour) + i);
            dtmDefault = dtmDefault.AddMinutes(-(dtmDefault.Minute)+30);
            dicHours.Add(dtmDefault.ToString("HH:mm"), dtmDefault.ToString("HH:mm"));
        }
        // NEXT THIS SHOULD LOOP FROM A ACOLLECTION, RETRIEVED FROM DATABASE
        String sxOutput = String.Empty;
        #region Update 30Nov2010 CodeBy Fajar
        String sxComboEventCode = CustomControls.Create_ComboBox(dtEventCode, KUFT.JENISID, 
            KControl.INPUT_ID, null, dtEventCode.Columns["P_EVENT_ID"].ToString(), dtEventCode.Columns["CODE"].ToString());
        String sxDateControl3 = CustomControls.Create_TextBox(KUFT.TANGGALEVENT, KControl.INPUT_ID, 
            uftData.dtmEventDate.ToString("dd-MMM-yyyy"), true, TextboxType.Date);
        //String sxDateControl4 = CustomControls.Create_TextBox(KUFT.STARTTIME, KControl.INPUT_ID,
        //    uftData.dtmStartTime.ToString("HH:mm"), true, TextboxType.DateTime);
        //String sxDateControl5 = CustomControls.Create_TextBox(KUFT.ENDTIME, KControl.INPUT_ID,
        //    uftData.dtmEndTime.ToString("HH:mm"), true, TextboxType.DateTime);
        //String sxHoursControl1 = CustomControls.Create_ComboBox(KUFT.STARTTIME, KControl.INPUT_ID, dicHours, null);
        //String sxHoursControl2 = CustomControls.Create_ComboBox(KUFT.ENDTIME, KControl.INPUT_ID, dicHours, null);
        String sxAttachmentControl = CustomControls.BuildEditor_FileUpload(KUFT.INVITATIONATTACHMENTID, 
            KFileHandler.UFT.INVITATION_ATTACHMENT, null, KControl.INPUT_ID, TextboxType.DocumentUpload);

        String sxHoursControl1 = String.Empty;
        sxHoursControl1 +=
            "<input type=\"button\" id=\"btnMinus\" class=\"btn\" " +
            "style=\"width:25px;\"" +
                "onclick=\"SetHours('MINUS','START');\" value=\"<\" />";
        sxHoursControl1 += CustomControls.Create_TextBox(KUFT.STARTTIME,
            KControl.INPUT_ID, "8:00", true, TextboxType.ReadOnly, false);
        sxHoursControl1 +=
            "<input type=\"button\" id=\"btnPlus\" class=\"btn\" " +
            "style=\"width:25px;\"" +
                "onclick=\"SetHours('PLUS','START');\" value=\">\" />";
        String sxHoursControl2 = String.Empty;
        sxHoursControl2 +=
            "<input type=\"button\" id=\"btnMinus\" class=\"btn\" " +
            "style=\"width:25px;\"" +
                "onclick=\"SetHours('MINUS','END');\" value=\"<\" />";
        sxHoursControl2 += CustomControls.Create_TextBox(KUFT.ENDTIME,
            KControl.INPUT_ID, "8:00", true, TextboxType.ReadOnly, false);
        sxHoursControl2 +=
            "<input type=\"button\" id=\"btnPlus\" class=\"btn\" " +
            "style=\"width:25px;\"" +
                "onclick=\"SetHours('PLUS','END');\" value=\">\" />";
        sxOutput += CustomControls.BuildFieldSet_PairedLabel("Jenis Event", sxComboEventCode);
        sxOutput += CustomControls.BuildEditor_LabelAndText(KUFT.EVENT_CODE, KControl.INPUT_ID, "Tema", 
            uftData.sxCode);
        sxOutput += CustomControls.BuildFieldSet_PairedLabel("Tanggal Event", sxDateControl3);
        sxOutput += CustomControls.BuildFieldSet_PairedLabel("Mulai", sxHoursControl1);
        sxOutput += CustomControls.BuildFieldSet_PairedLabel("Selesai", sxHoursControl2);
        sxOutput += CustomControls.BuildFieldSet_PairedLabel("Invitation Attachment", sxAttachmentControl);
        sxOutput += CustomControls.BuildEditor_LabelAndText(KUFT.LOCATION, KControl.INPUT_ID, "Lokasi",
            uftData.sxLocation);
        return sxOutput;
        #endregion
    }
    public static String BuildEditor_LastMinuteGuest()
    {
        String sxOutput = String.Empty;

        String sxOTFComboCustomer = CustomControls.Create_OTFComboBox(
            KUFT.DIRECTGUEST, KLOV.CourtesyCall.COMPANYLIST, null, null, TextboxType.Empty, String.Empty, "SelectCompany()");
        //String sxOTFComboContact = CustomControls.Create_OTFComboBox(KCC.CP_ID, KLOV.Generic.CONTACTPERSON, null, null, TextboxType.Empty, "-1", String.Empty);
        sxOutput += "<br/><div id=\"div1\" class=\"lnk\">ADD DIRECT GUEST</div><hr/>";
        sxOutput += CustomControls.BuildFieldSet_PairedLabel("Company Name", sxOTFComboCustomer);
        //sxOutput += CustomControls.BuildFieldSet_PairedLabel("Contact Person", sxOTFComboContact);
        sxOutput += "<dt>&nbsp;</dt><dd><input type=\"button\" id=\"btnAddLast\"" +
                    "class=\"btn\" style=\"width: 100px; float: left; margin-left: 5px; margin-right: 5px;\"" +
                    " onclick=\"addLastGuest();\" value=\"ADD\" /></dd><br/>";
        return sxOutput;
    }
    public static String BuildEventGuest(this DataTable dtEventList)
    {
        String sxOutput = String.Empty;
        if (dtEventList.Rows.Count > 0)
        {
            sxOutput = String.Format(
                        "<table cellspacing=\"0\" cellpadding=\"0\" id=\"{1}_{0}\" border=\"0\" class=\"cpT\">",
                        dtEventList.Rows[0]["T_RELATION_EVENT_ID"],
                        KUFT.ID,
                        dtEventList.Rows[0]["CODE"]);

            for (int i = 0; i < dtEventList.Rows.Count; i++)
            {
                sxOutput += String.Format(
                "<tr>" +
                    "<td valign=\"top\" style=\"padding-left:12px;\">" +
                     "<a class=\"cpH\" href=\"UFTGuest.aspx?eid={0}\">{2}</a>" +
                     "</td>" +
                "</tr>",
                dtEventList.Rows[i]["T_RELATION_EVENT_ID"],
                KUFT.ID,
                dtEventList.Rows[i]["CODE"]);
            }
            sxOutput += "</table>";
        }
        else
        {
            sxOutput = "No Data to Display";
        }

        return sxOutput;
    }
    public static String BuildEventDetails(this DataTable dtEventDetails)
    {
        // NEXT THIS ACOLLECTION SHOULD BE RETRIEVED FROM DATABASE
        Cached.EventTable evData = new Cached.EventTable();

        int iEventId = Convert.ToInt32(dtEventDetails.Rows[0]["T_RELATION_EVENT_ID"]);

        // NEXT THIS SHOULD LOOP FROM A ACOLLECTION, RETRIEVED FROM DATABASE
        String sxOutput = String.Empty;
        sxOutput += CustomControls.BuildFieldSet_PairedLabel("Jenis Event", evData.GetEventName(iEventId));
        sxOutput += CustomControls.BuildFieldSet_PairedLabel("Tema", dtEventDetails.Rows[0]["CODE"].ToString());
        sxOutput += CustomControls.BuildFieldSet_PairedLabel("Tanggal Event",
            dtEventDetails.Rows[0]["EVENT_DATE"].ToString());
        sxOutput += CustomControls.BuildFieldSet_PairedLabel("Lokasi", dtEventDetails.Rows[0]["LOCATION"].ToString());
        if (dtEventDetails.Rows[0]["INVITATION_ATTACHMENT_ID"] == DBNull.Value )
        {
            sxOutput += CustomControls.BuildFieldSet_PairedLabel("Invitation Attachment ID", "No Attachment");
        }
        else
        {
            sxOutput += CustomControls.BuildFieldSet_PairedLabel("Invitation Attachment ID", 
                dtEventDetails.Rows[0]["INVITATION_ATTACHMENT_ID"].ToString());
        }

        return sxOutput;
    }
    
    public static String BuildEditor_GuestInvitation(String sxControlId, String sxLOVName, 
        String sxValue, String sxCustId, String sxCompanyName, DataTable dtExistingGuest)
    {
        String sxOutput = String.Empty;

        String sxDef = String.Empty;
        for (int i = 0; i < dtExistingGuest.Rows.Count; i++ )
        {
            String sxTmpId = String.Empty;
            String sxTmpName = String.Empty;
            DataRow dr = dtExistingGuest.Rows[i];
            
                sxTmpId = dr["CONTACT_PERSON_ID"].ToString();
                sxTmpName = dr["NAME"].ToString();
            

            sxDef += CustomControls.BuildEditor_ComboBoxAndText(sxTmpId, KLOV.Generic.CONTACTPERSON, KControl.INPUT_ID, sxTmpName, sxTmpId, null, TextboxType.Empty, sxCustId);
        }

        sxDef += CustomControls.BuildEditor_ComboBoxAndText(sxControlId, KLOV.Generic.CONTACTPERSON, KControl.INPUT_ID, null, null, null, TextboxType.Empty, sxCustId);
        
        String sxHidden = CustomControls.Create_HiddenDiv(KUFT.HF_GUESTCOUNT,"0");
        String sxHidden2 = CustomControls.Create_HiddenDiv(KUFT.HF_INVITATIONID, sxValue);
    
        sxOutput = String.Format(
            "<div id=\"{1}_{0}\" class=\"popLOV\">" +
                "<fieldset class=\"m_fs_border\" id=\fs_lov_{0}\">" +
                    "<legend>" +
                        "<a class=\"lnk\" href=\"javascript:toggle('lov_{0}');\">Invite Guest for {3}</a>" +
                    "</legend>" +
                    "<dl class=\"m_fs\"><div id=\"div_invite_{0}\">{2}</div></dl>" +
                    "<div id=\"load_{0}\" style=\"float: right; padding-right: 10px;\"></div>" +
                    "<input type=\"button\" id=\"lnkdscd_lov_{0}\" class=\"btn\" style=\"float: right; margin-left: 5px; margin-right: 15px;\"" +
                        " onclick=\"closeGuestInvitation();\" value=\"cancel\" />" +
                    "<input type=\"button\" id=\"lnkedit_lov_{0}\" class=\"btn\" style=\"float: right; margin-left: 5px; margin-right: 5px;\"" +
                        " onclick=\"saveGuestInvitation('{0}');\" value=\"save\" />" +
                    "<div id=\"lnkadd_lov_{0}\" class=\"lnk\" style=\"float: left; margin-left: 15px; margin-right: 5px;\"" +
                        " onclick=\"inviteMore('{0}');\">invite more++</div>" +
                "</fieldset>" +
                "{4}{5}"+
            "</div>",
            sxControlId,
            KControl.GENERICPOPFORM_ID,
            sxDef, 
            sxCompanyName,
            sxHidden, sxHidden2
            );
        return sxOutput;
    }

    public static String BuildEditor_EmailType(String sxControlId)
    {
        String sxOutput = String.Empty;

        String sxDef = String.Empty;

        Dictionary<String, String> dicEmailType = new Dictionary<String, String>();
        dicEmailType.Add("BOTH", "BOTH");
        dicEmailType.Add("ATTACHMENT", "ATTACHMENT");
        dicEmailType.Add("EMBEDDED", "EMBEDDED");

        String sxCmbEmailType = CustomControls.Create_ComboBox(KUFT.EMAILTYPE, KControl.INPUT_ID, dicEmailType, "BOTH");
        sxDef += CustomControls.BuildFieldSet_PairedLabel("Tipe Attachment", sxCmbEmailType);

        sxOutput = String.Format(
            "<div id=\"{1}_{0}\" class=\"popLOV\">" +
                "<fieldset class=\"m_fs_border\" id=\fs_lov_{0}\">" +
                    "<legend>" +
                        "<a class=\"lnk\" href=\"javascript:toggle('lov_{0}');\">Choose Email Type</a>" +
                    "</legend>" +
                    "<dl class=\"m_fs\"><div id=\"div_invite_{0}\">{2}</div></dl>" +
                    "<div id=\"load_{0}\" style=\"float: right; padding-right: 10px;\"></div>" +
                    "<input type=\"button\" id=\"lnkdscd_lov_{0}\" class=\"btn\" style=\"float: right; margin-left: 5px; margin-right: 15px;\"" +
                        " onclick=\"closeChooseEmail();\" value=\"cancel\" />" +
                    "<input type=\"button\" id=\"lnkedit_lov_{0}\" class=\"btn\" style=\"float: right; margin-left: 5px; margin-right: 5px;\"" +
                        " onclick=\"DoSubmit();\" value=\"send email\" />" +
                    //"<input type=\"button\" id=\"lnk_lov_{0}\" class=\"btn\" style=\"float: right; margin-left: 5px; margin-right: 5px;\"" +
                    //    " onclick=\"NotSend();\" value=\"submit without email\" />" +
                "</fieldset>" +
            "</div>",
            sxControlId,
            KControl.GENERICPOPFORM_ID,
            sxDef
            );
        return sxOutput;
    }

    public static String BuildEditor_CloseEvent(this UFTData uftData)
    {
        String sxOutput = String.Empty;

        String sxAttachmentControl = CustomControls.BuildEditor_FileUpload(KUFT.EVENTATTACHMENTID,
            KFileHandler.UFT.EVENT_ATTACHMENT, null, KControl.INPUT_ID + "_" + KUFT.EVENTATTACHMENTID, TextboxType.DocumentUpload);
        String sxPresentationControl = CustomControls.BuildEditor_FileUpload(KUFT.PRESENTATIONID,
            KFileHandler.UFT.PRESENTATION, null, KControl.INPUT_ID + "_" + KUFT.PRESENTATIONID, TextboxType.DocumentUpload);
        sxOutput += CustomControls.BuildFieldSet_PairedLabel("Event Summary Attachment", sxAttachmentControl);
        sxOutput += CustomControls.BuildFieldSet_PairedLabel("Event Presentation File", sxPresentationControl);
        return sxOutput;
    }

    public static String BuildEditor_EventLog(String sxEventId, String sxHandlerName, String sxEventName, DataTable dtExistingLog)
    {
        String sxOutput = String.Empty;
        String sxDef = String.Empty;
        String sxExisting = String.Empty;

        for (int i = 0; i < dtExistingLog.Rows.Count; i++)
        {
            DataRow dr = dtExistingLog.Rows[i];
            String sxFilename = dr["ORIGINAL_FILENAME"].ToString();
            String sxId = dr["T_FILE_UPLOAD_ID"].ToString();

            String sxLinkLog = CustomControls.Create_LinkDiv(KUFT.EVLID + sxId,
            "downloadFile('" + sxId + "');"
            , sxFilename);
            sxExisting += CustomControls.BuildFieldSet_PairedLabel("Log Files #" + (i + 1), sxLinkLog);
        }

        sxDef += CustomControls.BuildEditor_FileUpload(sxEventId, sxHandlerName, null, KControl.INPUT_ID, TextboxType.DocumentUpload);
        
        String sxHidden = CustomControls.Create_HiddenDiv(KUFT.HF_EVENTLOGCOUNT, "0");
        String sxHidden2 = CustomControls.Create_HiddenDiv(KUFT.HF_EVENTID, sxEventId);
        sxOutput = String.Format(
            "<div id=\"{1}_{0}\" class=\"popLOV\">" +
                "<fieldset class=\"m_fs_border\" id=\fs_lov_{0}\">" +
                    "<legend>" +
                        "<a class=\"lnk\" href=\"javascript:toggle('lov_{0}');\">Add Log Files for {4}</a>" +
                    "</legend>" +
                    "<dl class=\"m_fs\">" +
                    "<div id=\"div_log_{0}\">{6}<dt>{2}</dt><dd>&nbsp;</dd></div>" +
                    "</dl>" +
                    "<div id=\"load_{0}\" style=\"float: right; padding-right: 10px;\"></div>" +
                    "<input type=\"button\" id=\"lnkdscd_lov_{0}\" class=\"btn\" style=\"float: right; margin-left: 5px; margin-right: 15px;\"" +
                        " onclick=\"cancelLog({0});\" value=\"cancel\" />" +
                    "<input type=\"button\" id=\"lnksave_lov_{0}\" class=\"btn\" style=\"float: right; margin-left: 5px; margin-right: 5px;\"" +
                        " onclick=\"saveLog('{0}');\" value=\"save\" />" +
                    "<div id=\"lnkadd_lov_{0}\" class=\"lnk\" style=\"float: left; margin-left: 15px; margin-right: 5px;\"" +
                        " onclick=\"addMore('{0}');\">add more++</div>" +
                "</fieldset>" +
                "{3}{5}" +
            "</div>",
            sxEventId,
            KControl.GENERICPOPFORM_ID,
            sxDef,
            sxHidden,
            sxEventName,
            sxHidden2,
            sxExisting
            );
        return sxOutput;
    }
    public static String Build_HTMLMailBody(this UFTMailData uftMailData)
    {
        String sxOutput = String.Empty;

        sxOutput = String.Format(
            @"
            Dengan Hormat,<br/>
            kami bermaksud mengundang bpk/ibu {5} untuk menghadiri {0},<br/>
            yang akan diselenggarakan pada :<br/>
            <br/>
            Tanggal     : {1}<br/>
            Jam         : {2} s.d {6}<br/>
            Tema        : {3}<br/>
            Tempat      : {4}<br/>
            <br/>
            hormat kami,<br/>
            Customer Support<br/>",
            uftMailData.sxEvent,
            uftMailData.dtmEventDate.ToString("dd-MMMM-yyyy"),
            uftMailData.dtmStartTime.ToString("HH:mm"),
            uftMailData.sxCode,
            uftMailData.sxLocation,
            uftMailData.sxContactName,
            uftMailData.dtmEndTime.ToString("HH:mm")
            );

			//String sxAgenda = "<ol>";
        //for (int i = 0; i < idx; i++)
        //{
        //    sxAgenda += "<li></li>";
        //}
        //sxAgenda += "</ol>";

        sxOutput = String.Format(
            "<p style=\"text-align: left; font-family: Verdana; font-size: 11pt;\">"+
            "    Terima kasih atas kerjasama yang telah terjalin baik selama ini.</p>"+
            "<p style=\"text-align: left; font-family: Verdana; font-size: 11pt;\">" +
            "    Dalam rangka meningkatkan layanan Lintasarta yang telah diberikan, kami mengundang Bapak/Ibu terkait" +
            "    untuk hadir dalam acara Seminar dengan tema <b>{0}</b>. </p>"+
            "<p style=\"text-align: left; font-family: Verdana; font-size: 11pt;\">" +
            "    Target peserta adalah CEO, COO, Director,  Business Development Manager, Marketing & Sales Manager, Customer Service Manager, Finance Manager, Inventory Manager dan IT Manager.</p>"+
            "<p style=\"text-align: left; font-family: Verdana; font-size: 11pt;\">" +
            "    Dengan mengikuti forum ini diharapkan peserta dapat mengetahui dan mengerti :</p>" +
            "<ol>"+
			"    <li style=\"text-align: left; font-family: Verdana; font-size: 11pt;\">"+
            "       CRM & ERP Solution with SaaS (Software as a Service) and Pay as You Go Model - Joni Wong Angkasa, Regional Manager Netsuite.</li>" +
            "    <li style=\"text-align: left; font-family: Verdana; font-size: 11pt;\">"+
            "       Contact Center Solution - M. Iqbal, Head of IT, Parazelsus Indonesia.</li>" +
            "</ol>"+
            "<span style=\"text-align: left; font-family: Verdana; font-size: 11pt;\">"+
            "       Acara ini akan dilaksanakan pada :</span>" +
            "<table border=\"0\" width=\"50%\">"+
            "    <tr>"+
            "        <td style=\"width:30%; font-family: Verdana; font-size: 11pt;\">Tanggal</td>" +
            "        <td style=\"width:2%; font-family: Verdana; font-size: 11pt;\">:</td>" +
            "        <td style=\"width:68%; font-family: Verdana; font-size: 11pt;\">{1}</td>" +
            "    </tr>"+
            "    <tr>"+
            "        <td style=\"width:30%; font-family: Verdana; font-size: 11pt;\">Waktu</td>" +
            "        <td style=\"width:2%; font-family: Verdana; font-size: 11pt;\">:</td>" +
            "        <td style=\"width:68%; font-family: Verdana; font-size: 11pt;\">{2} s/d {3}</td>" +
            "    </tr>"+
            "    <tr>"+
            "        <td style=\"width:30%; font-family: Verdana; font-size: 11pt;\">Tempat</td>" +
            "        <td style=\"width:2%; font-family: Verdana; font-size: 11pt;\">:</td>" +
            "        <td style=\"width:68%; font-family: Verdana; font-size: 11pt;\">{4}</td>" +
            "    </tr>"+
            "</table>"+
            "<br />"+
            "<span style=\"text-align: left; font-family: Verdana; font-size: 11pt;\">" +
            "       Ketentuan registrasi sebagai berikut :</span>" +
            "<ul>"+
            "    <li style=\"text-align: left; font-family: Verdana; font-size: 11pt;\">" +
            "    Registrasi dapat dilakukan dengan reply email ini ke" +
            "    <a href=\"mailto:forum@lintasarta.co.id\">forum@lintasarta.co.id</a>" +
            "    atau telephone Indri (021-75924000 ext 3237/081806619413) atau Ratih Ana (08563461034)"+
            "    </li>"+
            "</ul>"+
            "<p style=\"text-align:left; font-family: Verdana; font-size: 11pt;\">" +
            "Mohon Konfirmasi kedatangan dapat kami terima paling lambat tanggal {5}"+
            "<br /><br />"+
            "Terima Kasih"+
            "<br /><br /><br /><br />"+
            "Forum Lintasarta"+
            "</p>",
            //uftMailData.sxEvent,
            uftMailData.sxCode.ToUpper(),
            uftMailData.dtmEventDate.ToString("dd-MMMM-yyyy"),
            uftMailData.dtmStartTime.ToString("HH:mm"),
            uftMailData.dtmEndTime.ToString("HH:mm"),
            uftMailData.sxLocation,
            uftMailData.dtmEventDate.AddDays(-1).ToString("dd-MMMM-yyyy")
            );
			
        return sxOutput;
    }
    public static String Build_PlainMailBody(this UFTMailData uftMailData)
    {
        String sxOutput = String.Empty;

        sxOutput = String.Format(
            @"
            Dengan Hormat,<br/>
            kami bermaksud mengundang bpk/ibu {5} untuk menghadiri {0},<br/>
            yang akan diselenggarakan pada :<br/>
            <br/>
            Tanggal     : {1}<br/>
            Jam         : {2} s.d {6}<br/>
            Tema        : {3}<br/>
            Tempat      : {4}<br/>
            <br/>
            Hormat kami,<br/>
            Customer Support<br/>",
            uftMailData.sxEvent,
            uftMailData.dtmEventDate.ToString("dd-MMMM-yyyy"),
            uftMailData.dtmStartTime.ToString("HH:mm"),
            uftMailData.sxCode,
            uftMailData.sxLocation,
            uftMailData.sxContactName,
            uftMailData.dtmEndTime.ToString("HH:mm")
            );
			
			//String sxAgenda = String.Empty;
        //for (int i = 0; i < idx; i++)
        //{
        //    sxAgenda += ".>   [isi]\n";
        //}

        sxOutput = String.Format(
            "    Terima kasih atas kerjasama yang telah terjalin baik selama ini.\n\n" +
            "    Dalam rangka meningkatkan layanan Lintasarta yang telah diberikan,\n"+
            "kami mengundang Bapak/Ibu terkait untuk hadir dalam acara Seminar dengan tema {0}.\n\n" +
            "    Target peserta adalah CEO, COO, Director,  Business Development Manager, Marketing & Sales Manager, Customer Service Manager, Finance Manager, Inventory Manager dan IT Manager.\n\n" +
            "    Dengan mengikuti forum ini diharapkan peserta dapat mengetahui dan mengerti :\n" +
            "    .>   CRM & ERP Solution with SaaS (Software as a Service) and Pay as You Go Model - Joni Wong Angkasa, Regional Manager Netsuite.\n" +
            "    .>   Contact Center Solution - M. Iqbal, Head of IT, Parazelsus Indonesia.\n\n" +
            "    Acara ini akan dilaksanakan pada : \n" +
            "    Tanggal      : {1}\n"+
            "    Waktu        : {2} s/d {3}\n" +
            "    Tempat       : {4}\n\n" +
            "    Ketentuan registrasi sebagai berikut :\n" +
            "    .>   Registrasi dapat dilakukan dengan reply email ini ke \n"+
            "         forum@lintasarta.co.id \n"+
            "         atau telephone Indri (021-75924000 ext 3237/081806619413) atau Ratih Ana (08563461034) \n\n" +
            "    Mohon Konfirmasi kedatangan dapat kami terima paling lambat tanggal {5} \n\n" +
            "    Terima Kasih" +
            "    \n\n\n\n\n" +
            "    Forum Lintasarta \n",
            //uftMailData.sxEvent,
            uftMailData.sxCode.ToUpper(),
            uftMailData.dtmEventDate.ToString("dd-MMMM-yyyy"),
            uftMailData.dtmStartTime.ToString("HH:mm"),
            uftMailData.dtmEndTime.ToString("HH:mm"),
            uftMailData.sxLocation,
            uftMailData.dtmEventDate.AddDays(-1).ToString("dd-MMMM-yyyy")
            );
        return sxOutput;
    }
    public static String BuildUFTCustomer_Filter()
    {
        String sxOutput = String.Empty;

        String sxOTFComboTema = CustomControls.Create_OTFComboBox(KUFT.FILTERTEMA, KLOV.UFT.FILTERTEMA, 
            null, null,TextboxType.Empty,null,"FilterTema()");

        sxOutput += CustomControls.BuildFieldSet_PairedLabel("TEMA", sxOTFComboTema);
        sxOutput +=
            "<dt>&nbsp;</dt><dd><input type=\"button\" id=\"btnAll\" class=\"btn\" " +
            "style=\"margin-left: 5px; margin-right: 5px; width:100px;\"" +
                "onclick=\"All();\" value=\"Show All\" /></dd> ";

        return sxOutput;
    }


    public static String Build_HTMLMailAssManBody(DataTable dtEventMail, List<CARandCPforEmail> lsCARandCP)
    {
        String sxOutput = String.Empty;

        sxOutput = String.Format(
            @"
            Dengan Hormat,<br/>
            Berikut update event {0},<br/>
            yang akan diselenggarakan pada :<br/>
            <br/>
            Tanggal     : {1}<br/>
            Jam         : {2} s.d {3}<br/>
            Tema        : {4}<br/>
            Tempat      : {5}<br/>
            <br/>",
            dtEventMail.Rows[0]["EVENT"].ToString(),
            Convert.ToDateTime(dtEventMail.Rows[0]["EVENT_DATE"]).ToString("dd/MMMM/yyyy"),
            Convert.ToDateTime(dtEventMail.Rows[0]["START_TIME"]).ToString("HH:mm"),
            Convert.ToDateTime(dtEventMail.Rows[0]["END_TIME"]).ToString("HH:mm"),
            dtEventMail.Rows[0]["CODE"].ToString(),
            dtEventMail.Rows[0]["LOCATION"].ToString()
            );

        sxOutput +=
            "Berikut adalah data undangan: " +
            "<table border=\"1\">" +
            "   <tr>" +
            "       <td>COMPANY</td>" +
            "       <td>CONTACT PERSON</td>" +
            "       <td>CAR</td>" +
            "   </tr>";

        foreach (CARandCPforEmail CARandCP in lsCARandCP)
        {
            if (!String.IsNullOrEmpty(CARandCP.sxCAR))
            {
                sxOutput += String.Format(
                    "<tr>" +
                    "   <td>{0}</td>" +
                    "   <td>{1}</td>" +
                    "   <td>{2}</td>" +
                    "</tr>",
                    CARandCP.sxCompanyName,
                    CARandCP.sxContactName,
                    CARandCP.sxCAR);
            }
        }

        sxOutput +=
            "</table>";

        return sxOutput;
    }
    public static String Build_PlainMailAssManBody(DataTable dtEventMail, List<CARandCPforEmail> lsCARandCP)
    {
        String sxOutput = String.Empty;

        sxOutput = String.Format(
                    @"
                    Dengan Hormat,<br/>
                    Berikut update event {0},<br/>
                    yang akan diselenggarakan pada :<br/>
                    <br/>
                    Tanggal     : {1}<br/>
                    Jam         : {2} s.d {3}<br/>
                    Tema        : {4}<br/>
                    Tempat      : {5}<br/>
                    <br/>",
                    dtEventMail.Rows[0]["EVENT"].ToString(),
                    Convert.ToDateTime(dtEventMail.Rows[0]["EVENT_DATE"]).ToString("dd/MMMM/yyyy"),
                    Convert.ToDateTime(dtEventMail.Rows[0]["START_TIME"]).ToString("HH:mm"),
                    Convert.ToDateTime(dtEventMail.Rows[0]["END_TIME"]).ToString("HH:mm"),
                    dtEventMail.Rows[0]["CODE"].ToString(),
                    dtEventMail.Rows[0]["LOCATION"].ToString()
                    );

        sxOutput +=
            "Berikut adalah data undangan: " +
            "COMPANY    ||CONTACT PERSON    ||CAR";

        foreach (CARandCPforEmail CARandCP in lsCARandCP)
        {
            sxOutput += String.Format(
                "{0}    ||{1}   ||{2}",
                CARandCP.sxCompanyName,
                CARandCP.sxContactName,
                CARandCP.sxCAR);
        }

        sxOutput +=
            "</table>";

        return sxOutput;
    }

    public static String BuildEditor_Reason(String sxControlId)
    {
        return BuildEditor_Reason(sxControlId, String.Empty);
    }
    public static String BuildEditor_Reason(String sxControlId, String sxCompanyId)
    {
        String sxOutput = String.Empty;

        String sxDef = String.Empty;

        String sxOTFReason = CustomControls.Create_OTFComboBox(KUFT.REASON, KLOV.UFT.REASON,
            null, null, TextboxType.ReadOnly, null, "Reason()");
        sxDef += CustomControls.BuildFieldSet_PairedLabel("Alasan", sxOTFReason);
        if (String.IsNullOrEmpty(sxCompanyId))
        {
            sxOutput = String.Format(
                "<div id=\"{1}_{0}\" class=\"popLOV\">" +
                    "<fieldset class=\"m_fs_border\" id=\fs_lov_{0}\">" +
                        "<legend>" +
                            "<a class=\"lnk\" href=\"javascript:toggle('lov_{0}');\">Choose Reason</a>" +
                        "</legend>" +
                        "<dl class=\"m_fs\"><div id=\"div_invite_{0}\">{2}</div></dl>" +
                        "<div id=\"load_{0}\" style=\"float: right; padding-right: 10px;\"></div>" +
                        "<input type=\"button\" id=\"lnkdscd_lov_{0}\" class=\"btn\" style=\"float: right; margin-left: 5px; margin-right: 15px;\"" +
                            " onclick=\"closeReason();\" value=\"cancel\" />" +
                        "<input type=\"button\" id=\"lnkedit_lov_{0}\" class=\"btn\" style=\"float: right; margin-left: 5px; margin-right: 5px;\"" +
                            " onclick=\"DoSubmitReason({0});\" value=\"save reason\" />" +
                    "</fieldset>" +
                "</div>",
                sxControlId,
                KControl.GENERICPOPFORM_ID,
                sxDef
                );
        }
        else
        {
            sxOutput = String.Format(
                "<div id=\"{1}_{0}\" class=\"popLOV\">" +
                    "<fieldset class=\"m_fs_border\" id=\fs_lov_{0}\">" +
                        "<legend>" +
                            "<a class=\"lnk\" href=\"javascript:toggle('lov_{0}');\">Choose Reason</a>" +
                        "</legend>" +
                        "<dl class=\"m_fs\"><div id=\"div_invite_{0}\">{2}</div></dl>" +
                        "<div id=\"load_{0}\" style=\"float: right; padding-right: 10px;\"></div>" +
                        "<input type=\"button\" id=\"lnkdscd_lov_{0}\" class=\"btn\" style=\"float: right; margin-left: 5px; margin-right: 15px;\"" +
                            " onclick=\"closeReason();\" value=\"cancel\" />" +
                        "<input type=\"button\" id=\"lnkedit_lov_{0}\" class=\"btn\" style=\"float: right; margin-left: 5px; margin-right: 5px;\"" +
                            " onclick=\"DoSubmitReason({0},{3});\" value=\"save reason\" />" +
                    "</fieldset>" +
                "</div>",
                sxControlId,
                KControl.GENERICPOPFORM_ID,
                sxDef,
                sxCompanyId
                );
        }
        return sxOutput;
    }
    public static String GetConfirmColumn(String sxId, String sxStatus)
    {
        String sxOutput = String.Empty;
        if (sxStatus.ToUpper().Equals("HADIR"))
        {
            sxOutput = "-";
        }
        else
        {
            sxOutput = String.Format("<a href=\"javascript:DoReason('{0}');\">ALASAN</a>",
            sxId);
        }
        return sxOutput;
    }
	
	public static String GetHTMLEmail(this EmailBodyData ebData)
    {
        String sxOutput = String.Empty;
        if (ebData.iEventId > 0)
        {
            sxOutput = DBQuery.EventTable.GetHTMLEmail(ebData.iEventId);
        }
        return sxOutput;
    }
    public static String BuildEditor_HTMLEmail(this EmailBodyData ebData)
    {
        String sxOutput = String.Format(
            "<textarea class=\"m_taFw\" name=\"{0}\" id=\"{0}\">{1}</textarea>",
            KControl.TEXTAREA_ID,
            ebData.GetHTMLEmail());

        return sxOutput;
    }
    public static String BuildFieldSet_HTMLEmail(this EmailBodyData ebData)
    {
        String sxOutput = ebData.GetHTMLEmail();

        return sxOutput;
    }

    public static String GetPlainEmail(this EmailBodyData ebData)
    {
        String sxOutput = String.Empty;
        if (ebData.iEventId > 0)
        {
            sxOutput = DBQuery.EventTable.GetPlainEmail(ebData.iEventId);
        }
        return sxOutput;
    }
    public static String BuildEditor_PlainEmail(this EmailBodyData ebData)
    {
        String sxOutput = String.Format(
            "<textarea class=\"m_taFw\" name=\"{1}\" id=\"{0}\">{2}</textarea>",
            KUFT.UFTPLAINMAIL,
            KControl.INPUT_ID,
            ebData.GetPlainEmail());

        return sxOutput;
    }
    public static String BuildFieldSet_PlainEmail(this EmailBodyData ebData)
    {
        String sxOutput = String.Format(
            "<textarea class=\"m_taFw\" name=\"{1}\" id=\"{0}\" disabled=\"true\">{2}</textarea>",
            KUFT.UFTPLAINMAIL,
            KControl.INPUT_ID,
            ebData.GetPlainEmail());

        return sxOutput;
    }
}